
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel=stylesheet href='include/hoj.css' type='text/css'>
</head>
<body>
<center>
<div style="width:90%; text-align:left">
<img src="image/logo.png"/>
</div>
<table width=96%> 
	<tr align="center" class='hd' valign="top">
				<th><a href="faqs.php">F.A.Qs</a></th>
		<th><a href="./bbs.php">Web Board</a></th>
		<th><a href="./">Home</a></th>
		<th><a href="./problemset.html">ProblemSet</a></th>
		<th><a href="./status.php">Status</a></th>
		<th><a href="./ranklist.php">Ranklist</a></th>
		<th><a href="./contest.php">Contest</a></th>
		<th><a href=loginpage.php>Login</a></th><th><a href=registerpage.php>Register</a></th>	</tr>
</table>
</center>
<center>
<div class="notice">
	<div>
		<B>Notice:</B>鉴于种种原因，本OJ自下周星期一（3月5号）开始不再全面开放，请各位做好善后事宜，谢谢合作。	</div>
</div>
</center>
</div>
<title>Problem 2319. -- 黑白棋游戏 -- 衡阳八中OJ离线版-2012-02-29</title><center><h2>2319: 黑白棋游戏</h2><span class=green>Time Limit: </span>10 Sec&nbsp;&nbsp;<span class=green>Memory Limit: </span>128 MB<br><span class=green>Submit: </span>7&nbsp;&nbsp;<span class=green>Solved: </span>2<br>[<a href='submitpage.php?id=2319'>Submit</a>][<a href='problemstatus.php?id=2319'>Status</a>][<a href='bbs.php?id=2319'>Discuss</a>]</center><h2>Description</h2><div class=content><div class="Section0" style="layout-grid:  15.6pt none">
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">黑白棋游戏是这样玩的：首先<font face="Times New Roman">GEN</font><font face="宋体">随机生成</font><font face="Times New Roman">N</font><font face="宋体">个</font><font face="Times New Roman">01</font><font face="宋体">序列，</font><font face="Times New Roman">0</font><font face="宋体">表示白棋，</font><font face="Times New Roman">1</font><font face="宋体">表示黑棋。接着两个人轮流按如下规则取棋：首先选取一个非空的</font><font face="Times New Roman">01</font><font face="宋体">序列，然后从该序列的左边开始连续取若干个棋子，这些被取的棋子中最多只能有一个黑棋，且该黑棋必需恰好是连续取的最后一个棋子，比如当前的序列为</font><font face="Times New Roman">001001</font><font face="宋体">，则可以取走的棋子有三种情况，分别为：</font><font face="Times New Roman">0</font><font face="宋体">，</font><font face="Times New Roman">00</font><font face="宋体">，</font><font face="Times New Roman">001</font><font face="宋体">。如果某人没有棋子可取了，则他负。</font></span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">你通过特殊手段得到了<font face="Times New Roman">GEN</font><font face="宋体">生成时每一行生成的白棋数目和黑棋数目，由于不知道它们的排列情况，你做不到必胜，你只想知道你先手获胜的概率有多大</font><font face="Times New Roman">(</font><font face="宋体">假设你和你的对手都无限聪明</font><font face="Times New Roman">)</font><font face="宋体">。</font></span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
</div>
<!--EndFragment--></div><h2>Input</h2><div class=content><p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span>&nbsp;</p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">第一行一个数<font face="Times New Roman">N</font><font face="宋体">。</font></span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">第二行<font face="Times New Roman">N</font><font face="宋体">个数，第</font><font face="Times New Roman">i</font><font face="宋体">个数表示第</font><font face="Times New Roman">i</font><font face="宋体">个</font><font face="Times New Roman">01</font><font face="宋体">序列中黑棋的个数。</font></span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">第三行<font face="Times New Roman">N</font><font face="宋体">个数，第</font><font face="Times New Roman">i</font><font face="宋体">个数表示第</font><font face="Times New Roman">i</font><font face="宋体">个</font><font face="Times New Roman">01</font><font face="宋体">序列中白棋的个数。</font></span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p></div><h2>Output</h2><div class=content><p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">仅一行，一个保留<font face="Times New Roman">6</font><font face="宋体">为小数的的实数表示先手获胜的概率。</font></span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p></div><h2>Sample Input</h2>
			<div class=content><span class=sampledata>1<br />
<br />
1<br />
<br />
1<br />
<br />
<br />
</span></div><h2>Sample Output</h2>
			<div class=content><span class=sampledata>0.500000<br />
</span></div><h2>HINT</h2>
			<div class=content><p><p></p><br />
<p><br /><br />
样例解释</p><br />
<p>若生成序列为01，则先手必胜；若生成序列为10，则后手必胜。</p><br />
<p>两种情况出现的概率均为0.5，故先手获胜的概率为0.5。</p><br />
<p>0&lt;=每行的黑棋个数&lt;=100</p><br />
<p>0&lt;=每行的白棋个数&lt;=100</p><br />
<p>1&lt;=N&lt;=50</p><br />
<p>数据保证每个序列至少有一个棋子。<br /><br />
</p></p></div><h2>Source</h2>
			<div class=content><p><a href='problemset.html?search='></a></p></div><center>[<a href='submitpage.php?id=2319'>Submit</a>][<a href='problemstatus.php?id=2319'>Status</a>][<a href='bbs.php?id=2319'>Discuss</a>]</center>﻿<br>

<a href="./"><span class=red>HOME</span></a>
<a href="javascript:history.go(-1)"><span class=red>Back</span></a>

<hr>
<center>
	<div class="footer">
			<a href=setlang.php?lang=ko>한국어</a>&nbsp;
		<a href=setlang.php?lang=cn>中文</a>&nbsp;
		<a href=setlang.php?lang=fa>فارسی</a>&nbsp;
		<a href=setlang.php?lang=en>English</a>&nbsp;
		<a href=setlang.php?lang=th>ไทย</a>
	<br>		<div>版权所有 &copy;2008-2012 WaterPark Organization. | <script src="http://s21.cnzz.com/stat.php?id=2982771&web_id=2982771" language="JavaScript"></script>
</div>
		<div>Based on opensource project <a href="http://hustoj.googlecode.com">hustoj</a>.</div>
	</div>
</center>
</body>
</html>
